import java.util.*;

public class test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[n];
        long price = 0;
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i = 0;i < n;i++){
            price += a[i];
        }
        int sum = 0;
        int num = 0;
        for(int i = 0;i < n;i++) {
            sum += a[i];
            if(sum <= k){
                num++;
            } else {
                sum -= a[i];
                if(sum + (long)Math.ceil((double)a[i] / 2) <= k){
                    num++;
                    System.out.println(num);
                    return;
                } else {
                    System.out.println(num);
                    return;
                }
            }
        }
        System.out.println(num);
    }
}
